<?
include"../inc/config.inc.php";
if($_POST[MODE]=="ADD")
{
$news_id=$_POST[news_id];
$news_head=$_POST[news_head];
$news_detail=$_POST[news_detail];
$news_post=$_POST[news_post];
$news_date=$_POST[news_date];
$picname=$_FILES[news_image][name];
$tmp=$_FILES[news_image][tmp_name];
copy($tmp,"picture/$picname");
$sql="insert into news(news_id,news_head,news_detail,news_post,news_date,news_image) values('$news_id','$news_head','$news_detail','$news_post','$news_date','$news_image')";
mysql_query($sql) or die (mysql_error());
echo"<meta http-equiv='refresh' content='0;URL=news.php'>";
}
if($_GET[MODE]=="DEL")
{
$news_id=$_GET[news_id];
$news_head=$_GET[news_head];
$news_detail=$_GET[news_detail];
$news_post=$_GET[news_post];
$news_date=$_GET[news_date];
$news_image=$_GET[news_image];
$sql="delete from news where news_id='$news_id'";
mysql_query($sql) or die (mysql_error());
echo"<meta http-equiv='refresh' content='0;URL=news.php'>";
}
if($_POST[MODE]=="EDIT")
{
$news_id=$_POST[news_id];
$news_head=$_POST[news_head];
$news_detail=$_POST[news_detail];
$news_post=$_POST[news_post];
$news_date=$_POST[news_date];
$picname=$_FILES[news_image][name];
$tmp=$_FILES[news_image][tmp_name];
copy($tmp,"picture/$picname");
$sql="UPDATE news set news_id='$news_id',news_head='$news_head',news_detail='$news_detail',news_image='$picname' ,news_post='$news_post',news_date='$news_date' where news_id='$news_id'";
mysql_query($sql) or die (mysql_error());
echo"<meta http-equiv='refresh' content='0;URL=news.php'>";
}
?>